{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from common import *\n",
    "import urllib.parse as parse\n",
    "def commentOnIssue(url, comment):\n",
    "    headers['X-CSRF-Token'] = 'p6GefMGIU0KWCoWQTx6dffQKVSGsnaBZFfxtFGK0DgNoeGQ8pmI+B6GYVqcauw2d7A3vqlVmUuiXj1e6llQtYA=='\n",
    "    headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8'\n",
    "    headers['user-agent'] = 'PostmanRuntime/7.41.2'\n",
    "    headers['Accept'] = '*/*'\n",
    "    headers['Connection'] = 'keep-alive'\n",
    "    headers['accept-encoding'] = 'gzip, deflate, br'\n",
    "    headers['Postman-Token'] = 'aca4e1ad-5125-4cb4-925b-c315e207062d'\n",
    "    headers['Cookie'] = 'sensorsdata2015jssdkchannel=%7B%22prop%22%3A%7B%22_sa_channel_landing_url%22%3A%22%22%7D%7D; user_locale=zh-CN; oschina_new_user=false; tz=Asia%2FShanghai; Hm_lvt_24f17767262929947cc3631f99bfd274=1722926402,1722992932,1724064045; HMACCOUNT=6B63E7258241EAF5; remote_way=http; yp_riddler_id=beb85d16-f21d-4370-aea9-2cc6d74de714; project_pr_sort=closed_at+desc; visit-gitee--2024-08-27=1; visit-gitee--2024-08-28=1; user_return_to_0=%2F; gitee_user=true; BEC=1f1759df3ccd099821dcf0da6feb0357; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%229763246%22%2C%22first_id%22%3A%22191b1c58ad41cf-0510fa97903052-4c657b58-2073600-191b1c58ad515eb%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_utm_source%22%3A%22baidu%22%2C%22%24latest_utm_medium%22%3A%22sem%22%2C%22%24latest_utm_campaign%22%3A%22enterprise%22%2C%22%24latest_utm_content%22%3A%22competition%22%2C%22%24latest_utm_term%22%3A%22git%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkxMjY2YTgzNGExZjQtMDY1NDQ3YTM0YWNjNjEtN2Y1ZDU0N2UtMjA3MzYwMC0xOTEyNjZhODM0YmY3MSIsIiRpZGVudGl0eV9sb2dpbl9pZCI6Ijk3NjMyNDYifQ%3D%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%229763246%22%7D%2C%22%24device_id%22%3A%22191266a834a1f4-065447a34acc61-7f5d547e-2073600-191266a834bf71%22%7D; Hm_lpvt_24f17767262929947cc3631f99bfd274=1725345832; csrf_token=8Q5RtCKyZ0W8J2vahBpzj1nLIvFIXkRkbg6YYG6C%2F9I%2B16v0RVgKAIu1uO3Rv%2BNvQcyYerGlttXsfaLOmmLcsQ%3D%3D; gitee-session-n=NFJCQjc5dEdpRHJXa0ZMb0hpRkJBZWpuN0Y3VmlDMC9IVlpMcUtzSVFBeVJRaUdNNC82SzA4R0N5VjQ3Rm1kL3p6YmY4L2VMb1dSSnlsRFhCeWtCMk1yR2tZZ1VyN0twY0hhNlpvY1lvZGMrVXV2L1pXN1l3d2hTOTVyTFVEN0hxYXB4TXFlNzJxdjQvU2FsdUNYRDg0RjBOK09ZZXRCdFZSS3pVRVFhZ0dYbE5YWUQvQlI4dzYya1Z1WGY4TEdsUVVBU09WcXM3dmVwUTlFclJPY0tYY2paM0tVMkpXZ29QcytWUTdXQ20zMHFsdEZycTZsYkJ2WDh4M25EYzVmak96d1J3L2E5WjNFa0sxdUk1V3JsQlc0WTdGZ3JHNmpOT2ZTSFRzekl0S0FSU1J5NnhURW05YU9mMUljckFzeU0weTN2ZXlET2crWjlURlpyL2Y1bkRpVkZpaWlLdkVSdXFZMWJoVDA1WDdEVytvTGtHTExQeXdCQUQyRis2STVxRktqaGp5dFZ2b1hoaFkzQjFWVFU4Z2YwMmtQcXhMekthVHNHS1NiUVF3alBhK2tZUjJTQkJ1R1p6bGpLM0tYOVJRcUNURDdIWnRMQ2hGT1U4RHJhSkZ6b25paHc4cHpnQkRWL0h1Ti92d3IrSlBjSDRLZUdrRlpZUmZsTlNzd2lIdnZEZmhieWVtd3RZK1dkTmJ5Wmx3MTZkdlNDZmFodEVmVmZabmpxWllNUHpqcWF5bEY0UkdhUHpPUHZySUhzZ1Z1NHkyWmpLUWJCdmdKd0Q2K29wRXBLeHVWZkFna1J6WlI0T3owc1FtWTBHSFhFSk9tWTY4dXZHQWpzQXVaamowNW1tc0UzNnBXcXh1YUluNUNjZFpCZEdjQlcvNzhuUjc4R0o2NTJpRVk9LS1GOUZCa0g0alZJRlk2bkFPT0gwNWxRPT0%3D--0d61e10681a12c7fa5e50e5e45697719ba95134d'\n",
    "    data = {\n",
    "        'utf8': '✓',\n",
    "        'target_type': 'issue',\n",
    "        'target_id': 17947387,\n",
    "        'note[commit_id]': None,\n",
    "        'note[line_code]': None,\n",
    "        'note[noteable_id]': 17947387,\n",
    "        'note[noteable_type]': 'Issue',\n",
    "        'commit': None,\n",
    "        'note[reply_id]': None,\n",
    "        'note[note]': None,\n",
    "        'note[note]': 3,\n",
    "        'commit': '评论',\n",
    "    }\n",
    "    return requests.post(url, headers=headers,proxies=proxies)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Response [401]>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "requests.post('https://gitee.com/openharmony/kernel_linux_5.10/star', headers=headers,proxies=proxies)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Cookie': 'user_locale=zh-CN; oschina_new_user=false; sensorsdata2015jssdkchannel=%7B%22prop%22%3A%7B%22_sa_channel_landing_url%22%3A%22%22%7D%7D; tz=Asia%2FShanghai; slide_id=10; gitee_user=true; remote_way=http; yp_riddler_id=317fe5de-075d-443f-98ab-8ff9412dc1b6; remember_user_token=BAhbCFsGaQOu%2BZRJIiIkMmEkMTAkUkpJQ2Jvd1BNRllqTDZTVG43RkhLZQY6BkVUSSIXMTcyNTA5ODcxNC4wNTcxNTg3BjsARg%3D%3D--05ba0d59c4c0be32b82fdfc34351b336ec758907; visit-gitee--2024-08-28=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%229763246%22%2C%22first_id%22%3A%22191a7e426acd-00afb93476d5a64-26001151-1338645-191a7e426ad1264%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTkxYTdlNDI2YWNkLTAwYWZiOTM0NzZkNWE2NC0yNjAwMTE1MS0xMzM4NjQ1LTE5MWE3ZTQyNmFkMTI2NCIsIiRpZGVudGl0eV9sb2dpbl9pZCI6Ijk3NjMyNDYifQ%3D%3D%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%229763246%22%7D%2C%22%24device_id%22%3A%22191a7e426acd-00afb93476d5a64-26001151-1338645-191a7e426ad1264%22%7D; BEC=1f1759df3ccd099821dcf0da6feb0357; csrf_token=EP8l3dbMwGfEe4n8YmOKIMVDZJRf8IKBJda%2BztDvgy5KkmH1zM7dWnchjQK7OkOAbGmQxOBrTV2waPikyIHBmw%3D%3D; gitee-session-n=M0hRc000OHBEckJ6S3BSOStKRzRUaXdCb0c5eUVZWlRsdW8rYkZ5a001MFVOUzBpUExZUkt3eWVsVS9yTHB2Zm5jczFTQ0gzc3NUZGo5Q0tDZW5BUkhLdkF6SEZzK3ZYQk9mbHJ3TFNzbDlPMEdxa3ZWSVo0WW56bllLdStPWHluVXFHM1ZVUTg4eThXUGtwb09VNS9oOTh5YkFUcXRHd0praUNmTk9ybWsweFhBR09XU0NOTmp0TVRXWUpTOGhKdnBvM2FyTGl5QTF3d1dvaXZHblNoaHNCV1FyVTQ4M0RSYndCMENSQ2hPUk85SjAzM011QjZDNm4vNlIyNldpaVA5a3pXZXVuR253cDlQdjVvc3FwLzFpVGh6TjBRYjRXV2dDZlo2YmR3UmlQaU1CUDVEV29JMU9Tdy8xUFAxYjdSbGVRbFVwT3hNbEx3VVFOVlRGOHRQVUJNSVE2aGd1T1lLRXpZcTRVS055bW1EQWhINTdyaUREVzh2cy9UWmRiaUFpVmFhd2ljTXVKV01yM0kvU0QzYTdNWXMrSWVraVVwdDFsakxFN1RvaHBHSUFKVTltNTZWcTBmcTlEb280NjZEK3loOGRoUTVqZFJ5Q3pnTVhiNVRZRUZXazFpNWlJWUhuNlZOc01jdkNZaHo0K1YzRVR1ajg0MTJqMG9zTzlLVUNsME9iaUpsQjhnUlFwMjRCczFVM0dNSGgrNXJkRmpGYnlxamt2dDIrcGErTytSeWhJck0yYS9XcEQ1WmphUG12OW1aNHFTV0FKY0YzWEVtQ1A3YURmTWZiaVZZalJ6N1RzN2lrWGIwS0UxZEZHWVVvZVFGclZWbExGOG03dS0tTU41eG9nTDFmQnkzWWJUbVNUaFI2dz09--fd1378fe9952b8437873343f90f0cbaae2ed588d',\n",
       " 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',\n",
       " 'X-CSRF-Token': 'p6GefMGIU0KWCoWQTx6dffQKVSGsnaBZFfxtFGK0DgNoeGQ8pmI+B6GYVqcauw2d7A3vqlVmUuiXj1e6llQtYA=='}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "headers['X-CSRF-Token'] = 'p6GefMGIU0KWCoWQTx6dffQKVSGsnaBZFfxtFGK0DgNoeGQ8pmI+B6GYVqcauw2d7A3vqlVmUuiXj1e6llQtYA=='\n",
    "headers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "CVE-2024-26702\n"
     ]
    }
   ],
   "source": [
    "from service.GiteeService import *\n",
    "soup = getSoup(\"https://gitee.com/openharmony/kernel_linux_5.10/issues/IAOUWT?from=project-issue\")\n",
    "s = set([tag for tag in soup.find_all(\"div\", class_=\"git-issue-description markdown-body\")])\n",
    "import re\n",
    "cve = re.search(\"CVE-\\d{4}-\\d{4,7}\", s.pop().text)\n",
    "print(cve.group())\n",
    "# assert len(s) == 1\n",
    "# tag = s.pop()\n",
    "# print(tag)\n",
    "# if tag.p is None:\n",
    "#     print(None)\n",
    "# ret = str(tag.p.text)\n",
    "# if \"CVE-\" not in ret : \n",
    "#     print(None)\n",
    "# print(ret)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Issue('no':#IAQ190, 'title':【漏洞】 【OpenHarmony-4.1-Release】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ190?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetType':issue, 'targetId':18010836, 'commit':评论)\n",
      "Issue('no':#IAQ18Z, 'title':【漏洞】 【OpenHarmony-4.0-Release】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ18Z?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetType':issue, 'targetId':18010835, 'commit':评论)\n",
      "Issue('no':#IAQ18X, 'title':【漏洞】 【master】 CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IAQ18X?from=project-issue, 'state':待办的, 'cve':CVE-2024-42302, 'targetType':issue, 'targetId':18010833, 'commit':评论)\n",
      "Issue('no':#IALTJB, 'title':[安全问题]: [漏洞] [master] CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IALTJB?from=project-issue, 'state':已完成, 'cve':CVE-2024-42302, 'targetType':issue, 'targetId':17814215, 'commit':评论)\n",
      "待办的\n",
      "待办的\n",
      "待办的\n",
      "已完成\n"
     ]
    }
   ],
   "source": [
    "import service.GiteeService as gs\n",
    "import urllib.parse as parse\n",
    "def searchIssueByKeyword(keyword):\n",
    "    url = \"https://gitee.com/openharmony/kernel_linux_5.10/issues?utf8=%E2%9C%93\\\n",
    "    &state=all&issue_search={}\".format(parse.quote(keyword))\n",
    "    return gs.getIssueList(url)\n",
    "def searchIssuesByCVE(cve):\n",
    "    return searchIssueByKeyword(cve)\n",
    "def getHistoryIssueList(cve): # only return 不是代办的 issues，otherwise return []\n",
    "    l = searchIssuesByCVE(cve)\n",
    "    ret = []\n",
    "    for item in l:\n",
    "        if(item.state != \"待办的\"):\n",
    "            ret.append(item)\n",
    "    return ret\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Issue('no':#IALTJB, 'title':[安全问题]: [漏洞] [master] CVE-2024-42302, 'url':https://gitee.com//openharmony/kernel_linux_5.10/issues/IALTJB?from=project-issue, 'state':已完成, 'cve':CVE-2024-42302, 'targetType':issue, 'targetId':17814215, 'commit':评论)\n"
     ]
    }
   ],
   "source": [
    "for item in list:\n",
    "    if(item.state != \"待办的\"):\n",
    "        print(item)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
